package com.marvels.loanapply.mqueue.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.marvels.common.dto.MarvelsResultDTO;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.exception.MarvelsErrorCode;
import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.loanapply.dto.LoanApplyInfoDTO;
import com.marvels.loanapply.mqueue.service.IRabbitMQService;

@RestController
@RequestMapping("loanapply/loan/service")
public class LoanApplyController {
	@Autowired
	private IRabbitMQService rabbitMQService;
	
	/**试测
	 * @author 何杰
	 * 2018年4月21日
	 * @param content
	 * @return
	 *//*
	@RequestMapping("testRabbitMQ")
	@ResponseBody
	public MarvelsResultDTO testRabbitMQ(@RequestBody LoanApplyInfoDTO dto){
		try {
			rabbitMQService.send("loan_apply",dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), dto);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("marvels_error...",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(),MarvelsErrorCode.FAIL.getDesc(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("error...",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(),MarvelsErrorCode.ERROR.getDesc(), null);
		}
	}
	
	@RequestMapping("testRabbitMQString")
	@ResponseBody
	public MarvelsResultDTO testRabbitMQString(@RequestBody LoanApplyInfoDTO dto){
		try {
			rabbitMQService.sendString("acLoanStatus",dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), dto);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("marvels_error...",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(),MarvelsErrorCode.FAIL.getDesc(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("error...",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(),MarvelsErrorCode.ERROR.getDesc(), null);
		}
	}*/
	
}
